<template>
  <div class="vedio-preview" @click="$emit('update:videoShow', false)">
    <div class="vedio-box" @click.stop>
      <video :src="videoURL" autoplay></video>
    </div>
  </div>
</template>

<script>
export default {
  name: 'VedioPreview',
  props: {
    videoURL: {
      type: String,
      required: true
    },
    videoShow: {
      type: Boolean,
      default: false
    }
  },
  mounted () {
    window.addEventListener('keyup', e => {
      // console.log(e)
      if (e.key === 'Escape') {
        this.$emit('update:videoShow', false)
      }
    })
  }
}
</script>

<style lang="scss" scoped>
.vedio-preview{
  position: fixed;
  z-index: 9999999;
  background-color: rgba($color: #000000, $alpha: .3);
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  .vedio-box{
    position: absolute;
    width: 800px;
    height: 600px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
  video{
    position: absolute;
    width: 100%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}
</style>
